 <div class="w-content wrap-newsletter clearfix">
    <p class="txt-newsletter">Tilmeld dig vores nyhedsbrev og få 5% i rabat på alle onlinekøb. Vi udsender nyhedsbrev 1-2 gange om måneden.</p>
    <form id="newsletter_form_f" action="<?php echo str_replace('&', '&amp;', $action); ?>" method="post" enctype="multipart/form-data">
        <input type="text" id="subscriber_name_f" name="subscriber_name" class="txtInput ipname" placeholder="Indtast dit navn..."/>
        <input type="text" id="subscriber_email_f" name="subscriber_email" class="txtInput ipmail" placeholder="Indtast din e-mail adresse..."/>
        <a href="#" id="subscriber_button_f" class="btn btnTilmeld" >Tilmeld</a>
        <a href="#" id="unsubscriber_button_f" class="btn btnAfmeld">Afmeld </a>
    </form>
</div>

<script type="text/javascript">
	//var mail_filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var mail_filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z]{2,6})+$/;

    jQuery('#subscriber_button_f').on('click', function(event){
        event.preventDefault();

        if(jQuery('#subscriber_name_f').val() == ''){
            show_popup('Navn er ugyldig. Indtast en gyldig navn.');

            return false;
        }

        if(!mail_filter.test(jQuery('#subscriber_email_f').val())){
            show_popup('E-mailen er ugyldig. Indtast en gyldig e-mail.');

            return false;
        }

        jQuery.ajax({
            type: "POST",
            url: "<?php echo $subscriber_url; ?>",
            data: {'email': jQuery('#subscriber_email_f').val(), 'name': jQuery('#subscriber_name_f').val()},
            dataType: "text",
            success: function(data, text, request) {
                show_popup(data);
                post = true;
            } ,
            complete: function(xhr, status) {
            },
            async: false
        });

        return false;
    });

    jQuery('#unsubscriber_button_f').on('click', function(event){
        event.preventDefault();

        if(!mail_filter.test(jQuery('#subscriber_email').val())){
            show_popup('E-mailen er ugyldig. Indtast en gyldig e-mail.');

            return false;
        }

        jQuery.ajax({
            type: "POST",
            url: "<?php echo $unsubscriber_url; ?>",
            data: {email: jQuery('#subscriber_email').val()},
            dataType: "text",
            success: function(data, text, request) {
                show_popup(data);
                post = true;
            } ,
            complete: function(xhr, status) {
            },
            async: false
        });

        return false;
    });
</script>
